/**
 * Copyright © 2017-2018 Beijing Audiotone Technology Co.,Ltd.
 * All Rights Reserved.
 * This software is the confidential and proprietary information of
 * Beijing Audiotone Technology Co.,Ltd.
 * ("Confidential Information"). You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with Audiotone.
 * AUDIOTONE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. AUDIOTONE SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */
package pro.uccs.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/****************************************************************
 * Copyright © 2017,北京世纪奥通科技有限公司
 * All Rights Reserved.
 * 文件名称： MD5Coder.java
 * 摘    要： [简要描述本文件的内容]
 * 初始版本： 1.0.0
 * 原 作 者： songchen
 * 完成日期： 2018年07月10日 14时59分
 * 当前版本： 1.0.0
 * 作    者： songchen
 * 完成日期： 2018年07月10日 14时59分
 *
 *****************************************************************/
public final class MD5Coder {
    private static final int NUM_256 = 256;
    private static final int NUM_16 = 16;
    private static final int NUM_8 = 8;
    private static final int NUM_24 = 24;

    private MD5Coder() {
    }

    public static String encrypt(String source) {
        try {
            return Coder.encryptMD5(source);
        } catch (Exception var2) {
            return null;
        }
    }

    public static String encryptMD516(String source) {

        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(source.getBytes());
            byte[] b = md.digest();
            StringBuffer buf = new StringBuffer("");

            for(int offset = 0; offset < b.length; ++offset) {
                int i = b[offset];
                if (i < 0) {
                    i += 256;
                }

                if (i < 16) {
                    buf.append("0");
                }

                buf.append(Integer.toHexString(i));
            }

            return buf.toString().substring(8, 24);
        } catch (NoSuchAlgorithmException var6) {
            return null;
        }
    }
}
